package com.tomehay.termprojectmanage_server.controller;


import com.tomehay.termprojectmanage_server.pojo.DTO.LoginDto;
import com.tomehay.termprojectmanage_server.pojo.Model.Student;
import com.tomehay.termprojectmanage_server.pojo.Model.Teacher;
import com.tomehay.termprojectmanage_server.pojo.VO.ResultVO;
import com.tomehay.termprojectmanage_server.pojo.VO.StudentVO;
import com.tomehay.termprojectmanage_server.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
@RestController
@RequestMapping("api/student")
public class StudentController {

    @Autowired
    StudentService studentService;

    @PostMapping("/login")
    public ResultVO<StudentVO> login(@RequestBody LoginDto loginDto){ return studentService.Login(loginDto); }

    @RequestMapping("/Export")
    public void exportExcelModel(HttpServletResponse response) throws Exception {
        studentService.exportExcelModel(response);
    }

    @PostMapping("/BatchAddStudents")
    public ResultVO<Void> BatchAddStudents(@RequestParam(value = "file") MultipartFile multipartFile){
        return studentService.BatchAddStudents(multipartFile);
    }

    @RequestMapping("/GetStudentsByClazzID")
    public ResultVO<List<Student>> GetStudentsByClazzID(int clazz_id){
        return studentService.GetStudentsByClazzID(clazz_id);
    }

    @PostMapping("/CreateStudent")
    public ResultVO<Void> CreateStudent(@RequestBody Student student){
        return studentService.CreateStudent(student);
    }

    @DeleteMapping ("/RemoveStudent")
    public ResultVO<Void> RemoveStudent(int id){
        return studentService.RemoveStudent(id);
    }

    @PostMapping ("/UpdateStudent")
    public ResultVO<Void> UpdateStudent(@RequestBody Student student){
        return studentService.UpdateStudent(student);
    }


}
